import com.google.code.facebookapi.ProfileField;
import processing.core.*;


/**
 * Represents user with multiple different sized profile images.
 */
public class ProfileImage {

	//private Long uid;
	/**Url to the user's smalla square image.*/
	public String pic_square_url;
	/**Url to the user's profile image.*/
	public String pic_big_url;
	/**User's name.*/
	private String name;
	/**ColorCalculator that is used to calculate average color for small square images.*/
	public ColorCalculator c_calc;
	
	/**The small square image.*/
	private PImage pic_square = null;
	/**The full sized profile image.*/
	private PImage pic_big = null;
	/***/
	private ProfileField size_to_download;
	private int color;
	
	
	public ProfileImage(Long uid, String name, String pic_square_url, String pic_big_url, ColorCalculator calc) {
		//this.uid = uid;
		this.name = name;
		this.pic_square_url = pic_square_url;
		this.pic_big_url = pic_big_url;
	 	this.c_calc = calc;
	}

	/**
	 * Returns the name of the user that is represented by <code>ProfileImage</code>.
	 * 
	 * @return	name of the user
	 */
	public String getName() {
		return this.name;
	}
	
	/**
	 * Returns a small square image for the user represented by <code>ProfileImage</code>.
	 * 
	 * @return	the square image sized 50px*50px representing the user 
	 */
	public PImage getPic_square() {
		return this.pic_square;
	}

	/**
	 * Sets the user's small square picture to its destined parameter.
	 * 
	 * @param picSquare	the square image sized 50px*50px representing the user
	 */
	public void setPic_square(PImage picSquare) {
		this.pic_square = picSquare;
		if (this.pic_square != null) {
			this.color = this.c_calc.calculateColor(this.pic_square);
		} else {
			System.out.println("Null pic square");
		}
	}

	/**
	 * Returns the full sized profile image for the user represented by <code>ProfileImage</code>.
	 * 
	 * @return	the full sized profile image representing the user
	 */
	public PImage getPic_big() {
		return this.pic_big;
	}

	/**
	 * Sets the user's full sized profile image to its destined parameter.
	 * 
	 * @param picBig	the full sized profile image representing the user
	 */
	public void setPic_big(PImage picBig) {
		this.pic_big = picBig;
	}

	/**
	 * Returns the average color of the image calculated from the small square image.
	 * 
	 * @return	average color for the user
	 */
	public int getColor() {
		return this.color;
	}

	/**
	 * Returns the size of the picture to be downloaded.
	 * 
	 * @return	either PIC_SQUARE of PIC_BIG
	 */
	public ProfileField getSizeToDownload() {
		return this.size_to_download;
	}

	/**
	 * Sets the download size for user's picture to be downloaded.
	 * 
	 * @param size_to_download	either PIC_SQUARE of PIC_BIG
	 */
	public void setSizeToDownload(ProfileField size_to_download){
		this.size_to_download = size_to_download;
	}
	
}
